home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 25 April 1997
- //
- // Description:
- // This script provides an option box dialog for the mirrorJoint command.
- //
- // Input Arguments:
- // boolean showOptionBox true - show the option box dialog
- // false - just execute the command
- //
-
- // Procedure Name:
- // setOptionVars
- //
- // Description:
- // Initialize the option values.
- //
- // Input Arguments:
- // Whether to set the options to default values.
- //
- // Return Value:
- // None.
- //
- proc setOptionVars(int $forceFactorySettings)
- {
- // Mode.
- //
- if ($forceFactorySettings || !`optionVar -exists mirrorJointMode`) {
- optionVar -intValue mirrorJointMode 1;
- }
- if ($forceFactorySettings || !`optionVar -exists mirrorJointFunction`) {
- optionVar -intValue mirrorJointFunction 1;
- }
- if ($forceFactorySettings || !`optionVar -exists mirrorJointSearch`) {
- optionVar -stringValue mirrorJointSearch "";
- }
- if ($forceFactorySettings || !`optionVar -exists mirrorJointReplace`) {
- optionVar -stringValue mirrorJointReplace "";
- }
- }
-
- //
- // Procedure Name:
- // mirrorJointSetup
- //
- // Description:
- // Update the state of the option box UI to reflect the option values.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that UI object names can be
- // successfully resolved.
- //
- // forceFactorySettings - Whether the option values should be set to
- // default values.
- //
- // Return Value:
- // None.
- //
- global proc mirrorJointSetup(string $parent, int $forceFactorySettings)
- {
- // Retrieve the option settings
- //
- setOptionVars($forceFactorySettings);
-
- setParent $parent;
-
- // Query the optionVar's and set the values into the controls.
-
- // Mode.
- //
- radioButtonGrp -edit
- -select `optionVar -query mirrorJointMode`
- mirrorJointMode;
-
- // Function.
- //
- radioButtonGrp -edit
- -select `optionVar -query mirrorJointFunction`
- mirrorJointFunction;
-
- string $search = `optionVar -query mirrorJointSearch`;
- if (`textFieldGrp -exists mirrorJointSearchName`) {
- textFieldGrp -e -tx $search mirrorJointSearchName;
- }
- string $replace = `optionVar -query mirrorJointReplace`;
- if (`textFieldGrp -exists mirrorJointReplaceName`) {
- textFieldGrp -e -tx $replace mirrorJointReplaceName;
- }
- }
-
- //
- // Procedure Name:
- // mirrorJointCallback
- //
- // Description:
- // Update the option values with the current state of the option box UI.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI. Required so
- // that UI object names can be successfully resolved.
- //
- // doIt - Whether the command should execute.
- //
- // Return Value:
- // None.
- //
- // ********* Change 'mirrorJoint' in this proc to be the name of your command
- global proc mirrorJointCallback(string $parent, int $doIt)
- {
- setParent $parent;
-
- // Set the optionVar's from the control values, and then
- // perform the command.
-
- // Mode.
- //
- optionVar -intValue mirrorJointMode
- `radioButtonGrp -query -select mirrorJointMode`;
-
- // Founction.
- //
- optionVar -intValue mirrorJointFunction
- `radioButtonGrp -query -select mirrorJointFunction`;
-
- optionVar -stringValue mirrorJointSearch
- `textFieldGrp -query -tx mirrorJointSearchName`;
-
- optionVar -stringValue mirrorJointReplace
- `textFieldGrp -query -tx mirrorJointReplaceName`;
-
- if ($doIt) {
- performMirrorJoint 0;
- addToRecentCommandQueue "performMirrorJoint 0" "MirrorJoint";
- }
- }
-
- //
- // Procedure Name:
- // mirrorJointOptions
- //
- // Description:
- // Construct the option box UI. Involves accessing the standard option
- // box and customizing the UI accordingly.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc mirrorJointOptions()
- {
- // Name of the command for this option box.
- //
- string $commandName = "mirrorJoint";
-
- // Build the option box actions.
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- // Get the option box.
- //
- string $layout = getOptionBox();
- setParent $layout;
-
- // Pass the command name to the option box.
- //
- setOptionBoxCommandName($commandName);
-
- // Activate the default UI template.
- //
- setUITemplate -pushTemplate DefaultTemplate;
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- tabLayout -scr true -tv false;
- string $parent = `columnLayout -adjustableColumn 1`;
-
- radioButtonGrp -label "Mirror Across"
- -numberOfRadioButtons 3
- -label1 "XY"
- -label2 "YZ"
- -label3 "XZ"
- -select 1
- mirrorJointMode;
-
- radioButtonGrp -label "Mirror Function"
- -numberOfRadioButtons 2
- -label1 "Behavior"
- -label2 "Orientation"
- -select 1
- mirrorJointFunction;
-
- separator;
- text -align "left" -label " Replacement names for duplicated joints:";
- textFieldGrp -label "Search For:" -tx "" mirrorJointSearchName;
- textFieldGrp -label "Replace With:" -tx "" mirrorJointReplaceName;
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Deactivate the default UI template.
- //
- setUITemplate -popTemplate;
-
- // 'Apply' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- button -edit
- -l "Mirror"
- -command ($callback + " " + $parent + " " + 1)
- $applyBtn;
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " " + 1)
- $resetBtn;
-
- // Set the option box title.
- //
- setOptionBoxTitle("Mirror Joint Options");
-
- // Customize the 'Help' menu item.
- //
- setOptionBoxHelpTag( "MirrorJoint" );
-
- // Set the current values of the option box.
- //
- eval (($setup + " " + $parent + " " + 0));
-
- // Show the option box.
- //
- showOptionBox();
- }
-
- //
- // Procedure Name:
- // mirrorJointHelp
- //
- // Description:
- // Return a short description about this command.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // string.
- //
- proc string mirrorJointHelp()
- {
- return
- " Command: mirrorJoint - mirrors two skeletons.\n" +
- "Selection: joints";
- }
-
- //
- // Procedure Name:
- // assembleCmd
- //
- // Description:
- // Construct the command that will apply the option box values.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc string assembleCmd()
- {
- string $cmd = "mirrorJoint";
-
- setOptionVars(false);
-
- string $mode;
- int $selection = `optionVar -query mirrorJointMode`;
- switch ($selection) {
- case 1:
- $mode = " -mirrorXY";
- break;
- case 2:
- $mode = " -mirrorYZ";
- break;
- case 3:
- $mode = " -mirrorXZ";
- break;
- }
-
- $cmd = ($cmd + $mode);
-
- string $func;
- $selection = `optionVar -query mirrorJointFunction`;
- switch ($selection)
- {
- case 1:
- $func = " -mirrorBehavior";
- $cmd = ($cmd + $func);
- break;
- }
-
- string $search = `optionVar -query mirrorJointSearch`;
- string $replace = `optionVar -query mirrorJointReplace`;
- if (size($search) > 0 && size($replace) > 0) {
- $cmd += (" -searchReplace \""+$search+"\" \""+$replace+"\"");
- }
-
- return $cmd;
- }
-
- //
- // Procedure Name:
- // performMirrorJoint
- //
- // Description:
- // Perform the mirrorJoint command using the corresponding
- // option values. This procedure will also show the option box
- // window if necessary as well as construct the command string
- // that will invoke the mirrorJoint command with the current
- // option box values.
- //
- // Input Arguments:
- // 0 - Execute the command.
- // 1 - Show the option box dialog.
- // 2 - Return the command.
- //
- // Return Value:
- // None.
- //
- global proc string performMirrorJoint(int $action)
- {
- string $cmd = "";
-
- switch ($action) {
-
- // Execute the command.
- //
- case 0:
- // Retrieve the option settings
- //
- setOptionVars(false);
-
- // Get the command.
- //
- $cmd = `assembleCmd`;
-
- // Execute the command with the option settings.
- //
- evalEcho($cmd);
-
- break;
-
- // Show the option box.
- //
- case 1:
- mirrorJointOptions;
- break;
-
- // Return the command string.
- //
- case 2:
- // Retrieve the option settings.
- //
- setOptionVars (false);
-
- // Get the command.
- //
- $cmd = `assembleCmd`;
- break;
- }
- return $cmd;
- }
-
-